package cn.brilliantfuture.commentry.temp.impl;

import javax.ejb.Stateless;
import javax.jws.WebService;

import org.jboss.wsf.spi.annotation.WebContext;

import cn.brilliantfuture.commentry.temp.ActionTempMessageRemote;
import cn.brilliantfuture.commentry.temp.ActionTempMessageWebService;
import cn.brilliantfuture.commentry.util.BaseMessageImpl;
import cn.brilliantfuture.commentry.util.HttpUtil;

/**
 * 
 * Title: Communication Entry
 * 
 * Author:  LiTian  
 *
 * Date: 2011-11-2
 * 
 * Description: 操控温度类
 * 
 */
@Stateless
@WebService(endpointInterface = "cn.brilliantfuture.commentry.temp.ActionTempMessageWebService")
@WebContext(contextRoot = "/commentry", urlPattern = "/ActionTempMessageWebService")
public class ActionTempMessageImpl extends BaseMessageImpl implements ActionTempMessageRemote, ActionTempMessageWebService {

	public String actionTempValue(String deviceSn, int gridNo, int actionType,
			Float tempValue) {
		StringBuffer sb = new StringBuffer();
		sb.append(getRemoteUrl()).append("/action/temp?").append("cabinetID=");
		sb.append(deviceSn).append("&gridNo=").append(gridNo);
		sb.append("&actionType=").append(actionType);
		sb.append("&dataType=").append(1);
		if (null == tempValue)
			sb.append("&tempValue=");
		else
			sb.append("&tempValue=").append(tempValue.floatValue());

		return HttpUtil.getInvoke(sb.toString());
	}

	public String actionTempRange(String deviceSn, int gridNo, int actionType,
			float upperValue, float lowerValue, float upperAlarmValue,
			float lowerAlarmValue) {
		StringBuffer sb = new StringBuffer();
		sb.append(getRemoteUrl()).append("/action/temp?").append("cabinetID=");
		sb.append(deviceSn).append("&gridNo=").append(gridNo);
		sb.append("&actionType=").append(actionType);
		sb.append("&dataType=").append(2);
		sb.append("&tempValue=").append(upperValue);
		sb.append(",").append(lowerValue);
		sb.append(",").append(upperAlarmValue);
		sb.append(",").append(lowerAlarmValue);

		return HttpUtil.getInvoke(sb.toString());
	}

}
